<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>案件选择</title>
	<meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
              <input type="text" id="casetext" name="client_name"  placeholder="搜索内容" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <div class="layui-input-inline">
              <select id="stateclient" lay-verify="required">
                <option value="1">案号搜索</option>
				<option value="2">委托人搜索</option>
				<option value="3">对方当事人搜索</option>
				<option value="4">承办律师搜索</option>
				<option value="5">案由搜索</option>
				<option value="6">承办法院搜索</option>
              </select>
            </div>
          </div>
          <!--
          	查询按钮
          -->
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" id="seek" data-type="reload">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
      </div>

      <div class="layui-card-body" id="test1">
        <table id="clientall" lay-filter="test"></table>
        <div id="laypage"></div>
      </div>
    </div>
  </div>
<script src="../../layuiadmin/layui/layui.js"></script>
<script src="../../layuiadmin/jquery/jquery.min.js" type="text/javascript"></script>
<script>
	
  	function createrFormat(o){
                	return o;
    }
  	var msg=null;
   $(function(){
   		var state = $("#stateclient").val();
   		var casesys= $("#casetext").val();
   		
  	layui.use(['form','table',], function(){
  		var table = layui.table
            ,form = layui.form
		  //第一个实例
		  table.render({
		    elem: '#clientall'
		    ,url: 'http://localhost:8080/record/listallcase' //数据接口
		    ,cols: [[ //表头
		    	 {type:'checkbox', fixed: 'left',width:'7%'}
		      ,{field: 'caseId', title: '案号',width:'19%', sort: true, fixed: 'left'}
		      ,{templet:'<div>{{createrFormat(d.clientId.clientName)}}<\/div>', title: '委托人',width:'12%'}
		      ,{templet:'<div>{{createrFormat(d.oppositeId.clientName)}}<\/div>', title: '对方当事人',width:'12%'}
		      ,{field: 'realityMoney', title: '已到款',width:'12%'} 
		      ,{field: 'invoiceMoney', title: '已开票',width:'10%'}
		      ,{templet:'<div>{{createrFormat(d.mainLawyer.empName)}}<\/div>', title: '承办律师',width:'14%', sort: true}
		      ,{templet:'<div>{{createrFormat(d.closeDate)}}<\/div>', width: '14%', title: '收案日期'}
		    ]]
		    ,id:"clients"
		    ,page: true
		    ,where:{
		    	stateclient:state,
		    	casetext:casesys
		    }
		  });
 			
		var $ = layui.$, active = {
                reload: function(){
                	var state = $("#stateclient").val();
  					var casetext1 = $("#casetext").val();
                    //执行重载
                    table.reload('clients', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            stateclient:state,
		    				casetext:casetext1
                        }
                    });
                }
            };
            $('#seek').on('click', function () {
            	client = $("input[name='client_name']").val();
			    var type = $(this).data('type');
			    active[type] ? active[type].call(this) : '';
			})
           	table.on('checkbox(test)', function(obj){
			  if(obj.checked==true){
			  	if(obj.type=="all"){
			  		alert("不可全选！");
			  		var state = $("#stateclient").val();
  					var casetext1 = $("#casetext").val();
			  		table.reload('clients',{
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            stateclient:state,
		    				casetext:casetext1
                        }
                        });
			  	}else{
			  		msg= obj.data.caseId;
			  		window.parent.$("input[id='casechoice1'").val(msg);
			  		window.parent.$("input[id='clientname1'").val(obj.data.clientId.clientName);
			  		window.parent.$("input[id='caseemp1'").val(obj.data.mainLawyer.empName);
			  		window.parent.$("input[id='caseId1'").val(obj.data.caseId);
			  		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index); //再执行关闭  
			  		
			  	}
			  }else{
			  }
			});
			
		});
		
  });
	function downPanel(that) {
        var nodes = layui.jquery(".layui-form-selected");
        var hoverNodes = layui.jquery(".over-hover");
        var current = layui.jquery(that).parent();
        if (current.hasClass("layui-form-selected")) {
            nodes.removeClass("layui-form-selected");
            hoverNodes.removeClass("over-hover");
        } else {
            if (nodes.length > 0) {
                nodes.removeClass("layui-form-selected");
                hoverNodes.removeClass("over-hover");
            }
            current.addClass("layui-form-selected");
            current.parent(".layui-form").parent().addClass("over-hover");
        }

        layui.jquery(document).click(function(event){
            var _con2 = layui.jquery(".down-panel");
            if(!_con2.is(event.target) && (_con2.has(event.target).length ===0)){
                _con2.removeClass("layui-form-selected");
                hoverNodes.removeClass("over-hover");
                nodes.removeClass("layui-form-selected");
            }
        });
    }
//	function caseName(){
//		console.log("向父页面中的元素赋值！");
//		return msg;
//	}
  </script>
</body>
</html>
